{% load static %}
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>控制寄存器定义</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <script type="text/javascript" src="/static/js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
    <script src="/static/js/flow-meter.js" charset="utf-8"></script>
    <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">
                    <cite>控制寄存器定义</cite>
                </a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                </div>
                <div class="layui-card-body ">
                    <table lay-filter="register" id="register">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/html" id="toolbarDemo">

</script>
{% verbatim %}
<script type="text/html" id="displayOmit">
    <div><span title="{{d.remark}}">{{d.remark}}</span></div>
</script>
{% endverbatim %}
<script>

    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#begin_time' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end_time', //指定元素
        });

    });
</script>
<script>
    layui.use(['table', 'form', 'jquery', 'element'],
        function () {
            $ = layui.jquery;
            table = layui.table;
            form = layui.form;

            table.render({
                elem: '#register', //指定原始表格元素选择器（推荐id选择器）
                cols: [[
                    {
                        align: 'center',
                        numbers: true,
                        width: '5%',
                        title: '序号',
                        templet: function (data) {
                            return data.LAY_INDEX;
                        }
                    },
                    {field: 'name', title: '名称', align: 'center'},
                    {field: 'field_val', edit: 'text', title: '域值', align: 'center'},
                    {field: 'const_data', edit: 'text', title: '固定数据', align: 'center'},
                    {field: 'remark', edit: 'text', templet: '#displayOmit', title: '备注', align: 'center'},
                ]],
                url: '/handler/system/?action=query_control_register',
                toolbar: '#toolbarDemo',
                defaultToolbar: [],
            });

            //监听单元格编辑
            table.on('edit(register)',
                function (obj) {
                    let data = obj.data;
                    post({
                        "param": JSON.stringify(data),
                        "action": "update_control_register"
                    }, '/handler/system/', function (data) {
                        if (!data.success) {
                            layer.msg(data.msg, {icon: 5, time: 2000});
                        }
                    });
                });

        });
</script>
<script>var _hmt = _hmt || [];
(function () {

})();</script>

</html>